{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from numpy import *\n",
    "def loadDataSet(url):\n",
    "    with open(url) as fr:\n",
    "        dataMat = [];labelMat = []\n",
    "        for line in fr.readlines():\n",
    "            lineArr = line.strip().split()\n",
    "            dataMat = dataMat+[[float(lineArr[0]),float(lineArr[1])]]\n",
    "            labelMat =labelMat+[float(lineArr[2])]\n",
    "        return dataMat,labelMat\n",
    "def selectJrand(i,m):\n",
    "    j=i\n",
    "    while(j==i):\n",
    "        j = int(random.uniform(0,m))\n",
    "    return j\n",
    "def clipAlpha(aj,h,l):\n",
    "    if aj>h:\n",
    "        aj = h\n",
    "    if l>aj:\n",
    "        aj = l\n",
    "    return aj\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "def smoSimple(dataMat,classLabels,c,toler,maxIter):\n",
    "    dataMatrix =mat(dataMat)\n",
    "    labelMat = mat(classLabels).T\n",
    "    b= 0\n",
    "    m,n = shape(dataMatrix)\n",
    "    alphas = mat(zeros((m,1)))\n",
    "    iters = 0\n",
    "    while iters < maxIter :\n",
    "        alphaPairsChanged = 0\n",
    "        for i in range(m):\n",
    "            fXi = float(multiply(alphas,labelMat).T*(dataMatrix*dataMatrix[i,:].T))+b\n",
    "            Ei = fXi - labelMat[i]\n",
    "            if (labelMat[i]*Ei<-toler and alphas[i]<c) or (labelMat[i]*Ei>toler and alphas[i]>0) :\n",
    "                j = selectJrand(i,m)\n",
    "                fXj = float(multiply(alphas,labelMat).T*(dataMatrix*dataMatrix[j,:].T))+b\n",
    "                Ej = fXj -labelMat[j]\n",
    "                alphaIold = alphas[i].copy()\n",
    "                alphaJold = alphas[j].copy()\n",
    "                if labelMat[i] !=labelMat[j] :\n",
    "                    l = max(0,alphas[j]-alphas[i])\n",
    "                    h = min(c,c+alphas[j]-alphas[i])\n",
    "                else :\n",
    "                    l = max(0,alphas[j]+alphas[i]-c)\n",
    "                    h = min(c,alphas[j]+alphas[i])\n",
    "                if l==h :\n",
    "#                     print('l==h')\n",
    "                    continue\n",
    "                eta = 2* dataMatrix[i,:]*dataMatrix[j,:].T-dataMatrix[i,:]*dataMatrix[i,:].T-\\\n",
    "                dataMatrix[j,:]*dataMatrix[j,:].T\n",
    "                if eta>=0 :\n",
    "#                     print('eta>=0')\n",
    "                    continue\n",
    "                alphas[j] -= labelMat[j]*(Ei-Ej)/eta\n",
    "                alphas[j] = clipAlpha(alphas[j],h,l)\n",
    "                if abs(alphas[j]-alphaJold)<0.00001 :\n",
    "#                     print('j not moving enough')\n",
    "                    continue\n",
    "                alphas[i] += labelMat[j]*labelMat[i]*(alphaJold-alphas[j])\n",
    "                b1 = b-Ei-labelMat[i]*(alphas[i]-alphaIold)*dataMatrix[i,:]*dataMatrix[i,:].T-labelMat[j]*(alphas[j]-alphaJold)*dataMatrix[i,:]*dataMatrix[j,:].T\n",
    "                b2 = b-Ej-labelMat[i]*(alphas[i]-alphaIold)*dataMatrix[i,:]*dataMatrix[j,:].T-labelMat[j]*(alphas[j]-alphaJold)*dataMatrix[j,:]*dataMatrix[j,:].T\n",
    "                if 0<alphas[i]<c :\n",
    "                    b = b1\n",
    "                elif 0<alphas[j]<c :\n",
    "                    b = b2\n",
    "                else :\n",
    "                    b = (b1+b2)/2\n",
    "                alphaPairsChanged += 1\n",
    "#                 print('iters: %d i: %d,pairschanged %d' % (iters,i,alphaPairsChanged))\n",
    "        if alphaPairsChanged == 0 :\n",
    "            iters += 1\n",
    "        else :\n",
    "            iters = 0\n",
    "        print('iteration number: %d' % (iters))\n",
    "    return b,alphas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "fileurl = r'C:\\Users\\bgape\\Desktop\\computerS\\machinelearninginaction\\Ch06\\testSet.txt'\n",
    "dataArr,labelArr = loadDataSet(fileurl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 15\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 15\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 15\n",
      "iteration number: 16\n",
      "iteration number: 17\n",
      "iteration number: 18\n",
      "iteration number: 19\n",
      "iteration number: 20\n",
      "iteration number: 21\n",
      "iteration number: 22\n",
      "iteration number: 23\n",
      "iteration number: 24\n",
      "iteration number: 25\n",
      "iteration number: 26\n",
      "iteration number: 27\n",
      "iteration number: 28\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 15\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 15\n",
      "iteration number: 16\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 0\n",
      "iteration number: 1\n",
      "iteration number: 2\n",
      "iteration number: 3\n",
      "iteration number: 4\n",
      "iteration number: 5\n",
      "iteration number: 6\n",
      "iteration number: 7\n",
      "iteration number: 8\n",
      "iteration number: 9\n",
      "iteration number: 10\n",
      "iteration number: 11\n",
      "iteration number: 12\n",
      "iteration number: 13\n",
      "iteration number: 14\n",
      "iteration number: 15\n",
      "iteration number: 16\n",
      "iteration number: 17\n",
      "iteration number: 18\n",
      "iteration number: 19\n",
      "iteration number: 20\n",
      "iteration number: 21\n",
      "iteration number: 22\n",
      "iteration number: 23\n",
      "iteration number: 24\n",
      "iteration number: 25\n",
      "iteration number: 26\n",
      "iteration number: 27\n",
      "iteration number: 28\n",
      "iteration number: 29\n",
      "iteration number: 30\n",
      "iteration number: 31\n",
      "iteration number: 32\n",
      "iteration number: 33\n",
      "iteration number: 34\n",
      "iteration number: 35\n",
      "iteration number: 36\n",
      "iteration number: 37\n",
      "iteration number: 38\n",
      "iteration number: 39\n",
      "iteration number: 40\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAD4CAYAAADxeG0DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3de3iU1bX48e8mRDCAolyKiAgcPd4gcgkegcABE1qtF1qPnkdrTxXrw2lF66WI0hISjX24etfqQwXRemltbVFL2yOJcLjoERFI2gK2lJsp8itQRSFSMpP1+2MnEIZJMpl5Z/b7vr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ERuR+BnNPm8DyF4GxfLGJOLTeIvicivXMeTBqOAq4wx27HTY5cYY150G5LnaoAaEWl8N/VLbGIPm2Jgm4jsEZE64FfASMcxpcv/M8acBtBwm1QDe03k8D5wtjGmvzHmBOyiyhuOY/KUMcZg51U3icjDruNJBxGZJiJ9RKQf9u/wbREJ1ShORHYDHxljzmn4UhGw0WFI6bITuNgYk9fwb7eIEC7qNngDuLHhzzcCrydzkVQ7BAWeiESMMbcB/4NdHV8oIn9yHJbXRgH/BfzBGLOh4Ws/EJHfOoxJJed24KWGQcdWYKLjeDwnIu8ZY34JrMNWXK0nBNv1jTGvAGOB7saYGqAUmIVtWv9t7AvYtUldW7foK6VUsOnUilJKBZwmcqWUCjhN5EopFXCayJVSKuA0kSulVMBpIldKqYDTRK6UUgH3/wGTIkQ+wvKLTQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from matplotlib import pyplot as plt\n",
    "\n",
    "b,alphas = smoSimple(dataArr,labelArr,0.6,0.001,40)\n",
    "\n",
    "x = [];y = []\n",
    "w = array((0.0,0.0))\n",
    "for i in range(100):\n",
    "    if alphas[i]>0 :\n",
    "        x.append(dataArr[i][0])\n",
    "        y.append(dataArr[i][1])\n",
    "        w += array(alphas[i])[0][0]*labelArr[i]*array(dataArr[i])\n",
    "wx = arange(3,6,0.1)\n",
    "wy = -(array(b)[0][0]+w[0]*wx)/w[1]\n",
    "x1 = [];y1 = []\n",
    "x2 = [];y2 = []\n",
    "for i in range(len(labelArr)) :\n",
    "    if labelArr[i]>0 :\n",
    "        x1.append(dataArr[i][0])\n",
    "        y1.append(dataArr[i][1])\n",
    "    else :\n",
    "        x2.append(dataArr[i][0])\n",
    "        y2.append(dataArr[i][1]) \n",
    "plt.plot(wx,wy,color='r')\n",
    "plt.scatter(x,y,32,color='r')\n",
    "plt.scatter(x1,y1,12,color='g')\n",
    "plt.scatter(x2,y2,12,color='b')\n",
    "plt.legend(['line','marker','-1','1'],loc=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.scatter(x1,y1,15,color='g')\n",
    "plt.scatter(x2,y2,15,color='b')\n",
    "plt.legend(['-1','1','marker'],loc=0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "array(b)[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "array((0.0,0.0))+array(dataArr[2])*2*3\n",
    "array(alphas[2])[0][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 1 1 0 1 1]\n",
      " [1 1 1 0 1 0]\n",
      " [1 1 1 0 1 1]]\n",
      "<class 'tuple'>\n"
     ]
    }
   ],
   "source": [
    "from numpy import *\n",
    "b = array([[1,1,1,0,1,1],[1,1,1,0,1,0],[1,1,1,0,1,1]])\n",
    "print (mat(b).A)\n",
    "c = nonzero(b)\n",
    "print (type(c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'list' object has no attribute 'A'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-59-3d6a8f0ccc5c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mA\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      3\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'list' object has no attribute 'A'"
     ]
    }
   ],
   "source": [
    "a = list(range(10))\n",
    "b = a.A\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
